package eval.cm.xml.parser.simple.parser.util;

public abstract class ParserUtils {
	
	/**
	 * Checks whether the provided character is a valid for a tag value 
	 * @param token The character to be tested
	 * @return
	 */
	public static boolean isXmlTagValueAcceptedCharacter(final char token) {
		if(
			Character.isLetterOrDigit(token) ||
			Character.isWhitespace(token)
		) {
			return true;
		} else if( isAny( token, '>', '<', '\'' ) ) {
			return false;
		}
		return true;
	}
	
	/**
	 * Checks to see a character matches any of the given accepted chars
	 * @param checked The checked character
	 * @param accepted An array of accepted chars
	 * @return <code>true</code> if the checked character matches any of the accepted chars.
	 * <code>false</code> otherwise
	 */
	public static boolean isAny( final char checked, final char ... accepted) {
		for(char acc: accepted) {
			if(checked == acc ) {
				return true;
			}
		}
		return false;
	}

}
